// 让child的长和宽和parent的长和宽一致
// 输入参数为两个元素的类名或id等，格式:"定位器"
function elsize(parent,child){
	var width = $(parent).width();
	var height = $(parent).height();
	$(child).css({"width":width,"height":height});
}


//消除浮动
//输入参数为obj或parent的类名或id等，格式:"定位器"
//或者格式："["定位器","定位器"]"
function clearflcollapse(obj){
	console.log(obj.charAt(0));
	if(obj.charAt(0) != '['){
		var height = $(obj).outerHeight(true);
		$(obj).after("<div style='height:"+height+"px'></div>");
	}else{
		obj = JSON.parse(obj);
		console.log(obj);
		for(item in obj){
			console.log(obj[item]);
			var height = $(obj[item]).outerHeight(true);
			$(obj[item]).after("<div style='height:"+height+"px'></div>");
		}
	}
}


//消除一个父组件下所有组件产生的浮动
function clearflcollapseall(obj){
	console.log(obj.charAt(0));
	if(obj.charAt(0) != '['){
		var height = $(obj).outerHeight(true);
		$(obj).after("<div style='height:"+height+"px'></div>");
	}else{
		obj = JSON.parse(obj);
		console.log(obj);
		var allH = 0;
		for(item in obj){
			console.log(obj[item]);
			allH = $(obj[item]).outerHeight(true)+allH;
		}
		$(obj[item]).after("<div style='height:"+allH+"px'></div>");
		console.log(allH);
	}
}


//将子元素水平居中并且均匀分布在父元素内部
function innerdeployY(obj,deviation=0.96){
	var childs = $(obj).children();
	var parentW = $(obj).width()+0.0;
	var n = childs.length;
	var childW = parentW/n*deviation;
	$(obj).children().css({"width":childW+"px"});
	$(obj).css({"text-align":"center"});
}




//测试代码
function test(obj,deviation=0.96){
	var childs = $(obj).children();
	console.log(childs);
	var parentW = $(obj).width()+0.0;
	var n = childs.length;
	var childW = parentW/n*deviation;
	console.log(parentW);
	console.log(childW);
	$(obj).children().css({"width":childW+"px"});
	$(obj).css({"text-align":"center"});
}